package br.edu.ufcg.splab.util.commands;

import java.io.File;

import org.naturalcli.IParameterType;

public class ValidFilePathParameter implements IParameterType {
	
	/**
	 * {@inheritDoc}
	 */
	public String validationMessage(String value) {
		return this.validateParameter(value) ? null : value + " is not a valid file path.";
	}
	
	/**
	 * {@inheritDoc}
	 */
	public boolean validateParameter(String value) {
		try{
			new File(value);
			return true;
		}catch(NullPointerException e){
			return false;
		}
	}
	
	/**
	 * {@inheritDoc}
	 */
	public String getParameterTypeName() {
		return "validfilepath";
	}
	
	/**
	 * {@inheritDoc}
	 */
	public Object convertParameterValue(String value) {
		return new File(value);
	}

}
